#!/bin/bash

# 单独启动HTTP MCP服务器

set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

# 颜色定义
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m'

echo -e "${BLUE}🚀 Starting HTTP MCP Server...${NC}"

# 检查是否已编译
if [ ! -d "dist" ]; then
    echo -e "${YELLOW}📦 Building TypeScript...${NC}"
    npm run build
fi

# 启动HTTP服务器（带内存限制）
echo -e "${GREEN}✅ Starting server at http://localhost:3000${NC}"
node --max-old-space-size=4096 dist/mcp-http-server.js